package com.xiaoze.consumer.service.impl;

import com.xiaoze.consumer.entity.Type;
import com.xiaoze.consumer.sink.SinkConsumer;
import com.xiaoze.consumer.service.SinkDemo;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Service;

@Service
@EnableBinding(SinkConsumer.class)
public class SinkDemoImpl implements SinkDemo {

    @Override
    @StreamListener(SinkConsumer.INPUT)
    public void process(String message){
        System.out.println("接收到的信息是: " + message);
    }

    @Override
    @StreamListener(SinkConsumer.INPUT_SECOND)
    @SendTo(SinkConsumer.INPUT)
    public String processSecond(Type type) {
        System.out.println("接收到的Type信息是: " + type);
        return "我收到消息了！";
    }

}
